docker ps -a (or docker ps --all) lists ALL containers on the system — both running and stopped. Without the -a flag, docker ps only shows currently running containers. It is one of the most frequently used Docker commands for inspecting container state, finding container IDs, and debugging.
Up X hours/minutes — container is currently running
Exited (0) — container stopped successfully (exit code 0 = success)
Exited (1) — container stopped with error (non-zero = failure)
Exited (137) — container was killed (SIGKILL — often OOM or docker kill)
Created — container created but never started
Paused — container is paused (docker pause was called)
Restarting — container is in restart loop
Removing — container is being removed
Dead — container is in a broken state, needs force removal
docker ps — shows ONLY running containers (STATUS: Up)
docker ps -a — shows ALL containers regardless of state
docker ps -q — shows only IDs of running containers
docker ps -aq — shows only IDs of ALL containers
docker ps -l — shows the most recently created container
docker ps -n 5 — shows last 5 created containers
docker ps -as — shows running containers with disk size info
docker ps shows only running containers — always use -a to see everything
The STATUS column is the most important — it tells you exactly why a container stopped
Exit code 0 = clean stop, non-zero = error — use docker logs to investigate
Use -q flag to get just IDs — essential for scripting bulk operations
Use --filter to narrow down containers by status, name, image, or label
Use --format for clean readable output or JSON for programmatic processing
docker ps -aq is the foundation of most container cleanup scripts